<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script>
	/*  
	 $(document).ready(function() {

	 var date = new Date();
	 var d = date.getDate();
	 var m = date.getMonth();
	 var y = date.getFullYear();

	 $.ajax({
	 url : 'schedule.spring?action=scheduleCalendar',
	 method : 'post',
	 success : function(data) {
	 var calendar = $('#calendar').fullCalendar({
	 header : {
	 left : 'prev,next today',
	 center : 'title',
	 right : 'month,agendaWeek,agendaDay'
	 },
	 selectable : true,
	 selectHelper : true,
	 select : function(start, end, allDay) {
	 var title = prompt('Event Title:');
	 if (title) {
	 calendar.fullCalendar('renderEvent', {
	 title : title,
	 start : start,
	 end : end,
	 allDay : allDay
	 }, true // make the event "stick"
	 );
	 }
	 calendar.fullCalendar('unselect');
	 },
	 editable : true,
	 events : [ {
	 title : 'All Day Event',
	 start : new Date(y, m, 1)
	 }, {
	 title : 'Long Event',
	 start : new Date(y, m, d - 5),
	 end : new Date(y, m, d - 2)
	 }, {
	 id : 999,
	 title : 'Repeating Event',
	 start : new Date(y, m, d - 3, 16, 0),
	 allDay : false
	 }, {
	 id : 999,
	 title : 'Repeating Event',
	 start : new Date(y, m, d + 4, 16, 0),
	 allDay : false
	 }, {
	 title : 'Meeting',
	 start : new Date(y, m, d, 10, 30),
	 allDay : false
	 }, {
	 title : 'Lunch',
	 start : new Date(y, m, d, 12, 0),
	 end : new Date(y, m, d, 14, 0),
	 allDay : false
	 }, {
	 title : 'Birthday Party',
	 start : new Date(y, m, d + 1, 19, 0),
	 end : new Date(y, m, d + 1, 22, 30),
	 allDay : false
	 }, {
	 title : 'Click for Google',
	 start : new Date(y, m, 28),
	 end : new Date(y, m, 29),
	 url : 'http://google.com/'
	 } ]
	 });

	 }
	 });

	 });
	 */
	/*  
	$(document).ready(function() {

		var date = new Date();
		var d = date.getDate();
		var m = date.getMonth();
		var y = date.getFullYear();
		
		var calendar = $('#calendar').fullCalendar({
			header: {
				left: 'prev,next today',
				center: 'title',
				right: 'month,agendaWeek,agendaDay'
			},
			selectable: true,
			selectHelper: true,
			select: function(start, end, allDay) {
				var title = prompt('Event Title:');
				if (title) {
					calendar.fullCalendar('renderEvent',
						{
							title: title,
							start: start,
							end: end,
							allDay: allDay
						},
						true // make the event "stick"
					);
				}
				calendar.fullCalendar('unselect');
			},
			editable: true,
			 events: [
				{
					title: '달성',
					start: new Date(y, m, 1)
					
				},
				
				{
					title: 'Long Event',
					start: new Date(y, m, d-5),
					end: new Date(y, m, d-2)
				},
				{
					id: 999,
					title: 'Repeating Event',
					start: new Date(y, m, d-3, 16, 0),
					allDay: false
				},
				{
					id: 999,
					title: 'Repeating Event',
					start: new Date(y, m, d+4, 16, 0),
					allDay: false
				},
				{
					title: 'Meeting',
					start: new Date(y, m, d, 10, 30),
					allDay: false
				},
				{
					title: 'Lunch',
					start: new Date(y, m, d, 12, 0),
					end: new Date(y, m, d, 14, 0),
					allDay: false
				},
				{
					title: 'Birthday Party',
					start: new Date(y, m, d+1, 19, 0),
					end: new Date(y, m, d+1, 22, 30),
					allDay: false
				},
				{
					title: 'Click for Google',
					start: new Date(y, m, 28),
					end: new Date(y, m, 29),
					url: 'http://google.com/'
				}
			] 
		});
	});
	 */
	$(document).ready(
			function() {

				var calendar = $('#calendar').fullCalendar({
					header : {
						left : 'prev,next today',
						center : 'title',
						right : 'month,agendaWeek,agendaDay'
					},
					selectable : false,
					selectHelper : false,
					select : function(start, end, allDay) {
						onAddEvent(start, end, allDay);

					},
					editable : false,
					eventClick: function(event) {
				        if (event.url) {
				            window.open(event.url,'popUpWindow','height=500,width=500,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes');
				            return false;
				        }
				    }
					
				});

				$.ajax({
					url : 'schedule.spring?action=scheduleCalendar',
					type : 'POST',
					dataType : 'JSON',
					async : false,
					success : function(result) {
						$.each(result, function(i) {
							var d = i;
							var date = new Date(result[d].foodScheduleStartdate).format("yyyy-MM-dd");
			
							calendar.fullCalendar('renderEvent', {
								title : result[d].foodName,
								start : date,
								url : 'schedule.spring?action=CalendarPopup&ScheduleStartdate='+date,
								editable : false
							}, true);

						});
					},

				});

			});
</script>

<style>
body {
	margin-top: 40px;
	text-align: center;
	font-size: 14px;
	font-family: "Lucida Grande", Helvetica, Arial, Verdana, sans-serif;
}

#calendar {
	width: 991px;
	margin-top: 62px;
}
</style>
<body>
	<div id='calendar'></div>
</body>